import { createRouter, createWebHistory } from 'vue-router'

// 引入页面组件
import Home from '@/views/Home.vue'
import Overview from '@/views/About/Overview.vue'
import Director from '@/views/About/Director.vue'
import Structure from '@/views/About/Structure.vue'
import partyBuilding from '@/views/news/partyBuilding'
import newsBulletin from '@/views/news/newsBulletin'
import researchAchievements from '@/views/news/researchAchievements'
import notices from '@/views/news/notices'
import NewsDetail from '@/views/news/NewsDetail'
import CenterList from '@/views/contact/CenterList'
import GuestFeedback from '@/views/contact/GuestFeedback.vue'
import projects from '@/views/project/projects.vue'
import organizationalStructure from '@/views/support/organizationalStructure'
import talentExpertTeam from '@/views/support/talentExpertTeam'
import resourceSupport from '@/views/support/resourceSupport'


const routes = [
  {
    path: '/',          // 默认首页
    name: 'Home',
    component: Home
  },  
  { path: '/contact/CenterList', 
    name: 'CenterList', 
    component: CenterList 
  },
  {
    path: '/contact/GuestFeedback',
    name: 'GuestFeedback',
    component: GuestFeedback
  },  
  {
    path: '/about/overview',
    name: 'overview',
    component: Overview
  },
  {
    path: '/about/director',
    name: 'director',
    component: Director
  },
  {
    path: '/about/structure',
    name: 'structure',
    component: Structure
  },
  {
    path: '/news/partyBuilding',
    name: 'partyBuilding',
    component: partyBuilding
  },
{
  path: '/news/newsBulletin',
  name: 'newsBulletin',
  component: newsBulletin
},
{
  path: '/news/notices',
  name: 'notices',
  component: notices
},
{
  path: '/news/researchAchievements',
  name: 'researchAchievements',
  component: researchAchievements
},

{
  path: '/news/:id',
  name: 'NewsDetail',
  component: () => import('@/views/news/NewsDetail.vue'),
  props: true   
},
{
  path: '/project/projects',
  name: 'projects',
  component: projects
},
{
  path: '/support/organizationalStructure',
  name: 'organizationalStructure',
  component: organizationalStructure
},
{
  path: '/support/talentExpertTeam',
  name: 'talentExpertTeam',
  component: talentExpertTeam
},
{
  path: '/support/resourceSupport',
  name: 'resourceSupport',
  component: resourceSupport
},
{
  path: '/research-direction/researchDirection',
  name: 'researchDirection',
  component: () => import('@/views/research-direction/researchDirection.vue')
},
{
  path: '/support/memberProfile',
  name: 'MemberProfile',
  component: () => import('@/views/support/memberProfile.vue')
},
{
    path: '/:pathMatch(.*)*',   // 404 页面
    name: 'NotFound',
    component: () => import('@/views/error/404.vue')
}
]

const router = createRouter({
  history: createWebHistory(),  // 使用 History 模式
  routes,
  scrollBehavior(to, from, savedPosition) {
    return savedPosition || { top: 0 }
  }
})

export default router
